﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace NewestCPUProcess {
    class Program {
        static void Main() {
            var processes = Process.GetProcesses()
                .Select(process => {
                    try {
                        return new {
                            process.ProcessName,
                            process.StartTime,
                            process.MainWindowTitle
                        };
                    } catch (Exception ex) {
                        Console.WriteLine(ex.Message);
                        return new {
                            process.ProcessName,
                            StartTime = new DateTime(1970, 1, 1),
                            MainWindowTitle = ""
                        };
                    }
                })
                .OrderByDescending(x => x.ProcessName)
                //.Take(50)
                .ToList();

            foreach (var process in processes) {
                Console.WriteLine($"Process: {process.ProcessName} Start Time: {process.StartTime} Title: {process.MainWindowTitle}");
            }
        }
    }
}